 public static void main(String[] args) {

        double banlance = 0;
        boolean flag = true;
        Scanner scn = new Scanner(System.in);
        while(flag){
            System.out.println("=========家庭收支记账========");
            System.out.println(" 1、登记收入");
            System.out.println(" 2、登记支出");
            System.out.println(" 3、收支明细");
            System.out.println(" 4、退出");
            System.out.println("请选择(1-4)：");


            int res = scn.nextInt();
            if(res == 1){

                System.out.println("本次收入的金额为");
                double price = scn.nextDouble();
                System.out.println("本次收入的说明为");
                String a = scn.nextLine();
                banlance = banlance + price;

            }else if(res == 2){

                System.out.println("请输入支出的金额");
                double price2 = scn.nextDouble();
                System.out.println("本次支出的说明为");
                String b = scn.nextLine();
                if(price2 > banlance){
                    System.out.println("金额不足");
                }else if(price2 <= 0){
                    System.out.println("输入金额有误");
                }else{
                    banlance = banlance - price2;
                }

            }else if(res == 3){
            	System.out.println("收支" +"      "+"账号余额"+"        "+"收支金额"+"       "+"说明" );
            	System.out.println("收入" +"      "+banlance+"        "+price+"       "+a );
            	System.out.println("支出" +"      "+banlance+"        "+price2+"       "+b );
            }else if(res == 4){

                flag = false;
            }else{
                System.out.println("请选择正确的操作选项");
            }
        }
        scn.close();
    }
